
class MyQueue {
    int front = 0;
    int tail = 0;
    int k = 0;
    int[] arr;
    public MyQueue(int k) {
        this.k = k;
        arr = new int[k +1];
    }

    public boolean enQueue(int value) {
        if(isFull()){
            return false;
        }else{
            arr[tail] = value;
            tail++;
            return true;
        }
    }

    public boolean deQueue() {
        if(isEmpty()){
            return false;
        }else{
            if(front < k){
                front++;
            }else{
                front = 0;
            }

            return true;
        }
    }

    public int Front() {
        if(isEmpty()){
            return -1;
        }else{
            return arr[front];
        }
    }

    public int Rear() {
        if(isEmpty()){
            return -1;
        }else{
            return arr[tail-1];
        }
    }

    public boolean isEmpty() {
        return front == tail ;
    }

    public boolean isFull() {
        return (tail + 1) % (k+1) == front;
    }
}
public class MyCircularQueue {
    public static void main(String[] args) {
        MyQueue myQueue = new MyQueue(2);
        myQueue.enQueue(2);
        myQueue.enQueue(1);
        myQueue.deQueue();
        myQueue.enQueue(3);
        myQueue.deQueue();
        myQueue.enQueue(3);
        myQueue.deQueue();
        myQueue.enQueue(3);
        myQueue.deQueue();
        myQueue.Front();
    }
}
